﻿/***********************************************************************************************
 * 
 * ProjectName: WMSSoft.Lib.WinKStart
 * 
 * Description: Enum and Convert Class to work with Itemtypes
 * 
 * Created:     21.07.2012
 * 
 * Author:      matthias wagler - matthias@WMSSoft.de
 * 
 * Copyright:   Copyright 2012 by WMSSoft.de
 * 
 * Lizense:     GPLv3
 * 
 * History:     21.07.2012 - matthias wagler matthias@WMSSoft.de   -   Created
 *              27.01.2015 - matthias wagler matthias@WMSSoft.de   -   Add Enumeration Value Url     
 * 
 **********************************************************************************************/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WMSSoft.Lib.Enums
{
    /// <summary>
    /// Is used to spezify the Itemtype
    /// </summary>
    public enum eItemType
    {
        /// <summary>
        /// Itemtype is unknown
        /// </summary>
        None = 0,

        /// <summary>
        /// Item is a Folder with Links
        /// </summary>
        Folder = 1,

        /// <summary>
        /// Item is a Link to run a Program - Link
        /// </summary>
        Link = 2,

        /// <summary>
        /// Item is the Starmenus Root - Item
        /// </summary>
        Root,

        /// <summary>
        /// Item will be used to show informations
        /// </summary>
        Label,

        /// <summary>
        /// Item will used as a Filter (Initial - Category)
        /// </summary>
        Filter,

        /// <summary>
        /// Item is a Link to a Website
        /// </summary>
        URL
    }

    public static class cItemType
    {
        /// <summary>
        /// Return the Enum - ItemType - Value for the String
        /// </summary>
        /// <param name="Value">Value to get the Enumvalue</param>
        /// <returns>eItemType, None if the string has no match as enumvalue</returns>
        public static eItemType GetEnumValueFromString(string Value)
        {
            try
            {
                if (Value.ToUpper() == "FOLDER") return eItemType.Folder;
                else if (Value.ToUpper() == "LINK") return eItemType.Link;
                else if (Value.ToUpper() == "LABEL") return eItemType.Label;
                else if (Value.ToUpper() == "ROOT") return eItemType.Root;
                else if (Value.ToUpper() == "FILTER") return eItemType.Filter;
                else if (Value.ToUpper() == "URL") return eItemType.URL;
                else return eItemType.None;
            }
            catch
            {
                return eItemType.None;
            }
        }

        /// <summary>
        /// Return the string for the enumvalue
        /// </summary>
        /// <param name="Value"></param>
        /// <returns></returns>
        public static string GetStringFromEnum(eItemType Value)
        {
            try
            {
                switch (Value)
                {
                    case eItemType.Folder: return "Folder";
                    case eItemType.Filter: return "Filter";
                    case eItemType.Label: return "Label";
                    case eItemType.Link: return "Link";
                    case eItemType.None: return "None";
                    case eItemType.Root: return "Root";
                    case eItemType.URL: return "Url";
                    default: return "None";
                }
            }
            catch
            {
                return "None";
            }
        }
    }
}
